import java.io.IOException;

public class Main {

	/**
	 * @param args
	 * @throws IOException
	 */
	// using ramanujams

	private static double logPiByTwo = Math.log(Math.PI) / 2;

	public static void main(String[] args) throws IOException {
		java.io.BufferedReader r = new java.io.BufferedReader(
				new java.io.InputStreamReader(System.in));

		int number = Integer.parseInt(r.readLine());
		for (int i = 0; i < number; i++) {
			long result = 1;
			double num = Long.parseLong(r.readLine());
			if (num != 0 && num != 1) {
				double logn = Math.log(num);
				result = (long) (Math
						.floor((num * logn - num
								+ Math.log(num * (1 + 4 * num * (1 + 2 * num)))
								/ 6 + logPiByTwo)
								/ Math.log(10)) + 1);
			}
			System.out.println(result);
		}
	}
}
